package com.itboye.mengwu.app.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.itboye.inageview.RoundImageView;
import com.itboye.mengwu.R;
import com.itboye.mengwu.app.MainApplication;
import com.itboye.mengwu.data.model.HuiFuDetailModel;
import com.itboye.mengwu.data.model.HuiFuDetailModel.A;
import com.itboye.mengwu.data.model.TieZiBaoHanReply.GetAList.ReplyInfo;

public class ChaKanGengDuoPingLunAdapter extends BaseAdapter {

	HuiFuDetailModel dataList;
	String fid;
	String myId;

	public ChaKanGengDuoPingLunAdapter(String fid, HuiFuDetailModel dataList2) {
		this.dataList = dataList2;
		this.fid = fid;
	}

	@Override
	public int getCount() {

		return dataList.getComments().size();
	}

	@Override
	public Object getItem(int position) {

		return null;
	}

	@Override
	public long getItemId(int position) {

		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder;
		if (convertView == null) {
			holder = new ViewHolder();
			convertView = LayoutInflater.from(MainApplication.context).inflate(
					R.layout.item_luntan_pinglun, null);

			holder.txt_rname = (TextView) convertView
					.findViewById(R.id.txt_rname);
			holder.content = (TextView) convertView.findViewById(R.id.txt_content);
			holder.txt_rname2 = (TextView) convertView
					.findViewById(R.id.txt_rname2);

			// holder.delete.setOnClickListener(new OnClickListener() {
			//
			// @Override
			// public void onClick(View v) {
			// // TODO Auto-generated method stub
			// CommontItemBean commontBean= dataList.get((int) v.getTag());
			// final String tid =commontBean.getTid();
			// final String pid=commontBean.getPid();
			// final String id=commontBean.getId();
			//
			// MyJsonRequest.Builder<String> builder = new
			// MyJsonRequest.Builder<String>().apiVer("100")
			// .typeKey("BY_ForumPost_DeleteComment")
			// .param("tid",tid)
			// .param("id",id )
			// .param("pid",pid)
			// .param("uid", (String)SPUtils.get(App.ctx, null,
			// SPContants.USER_ID , ""))
			// .requestListener(new XRequestListener<String>() {
			//
			// @Override
			// public void onResponse(String orderBean) {
			//
			// Toast.makeText(App.ctx, "删除成功", 1).show();
			// Iterator<CommontItemBean> itr=dataList.iterator();
			// while(itr.hasNext()){
			// CommontItemBean bean=itr.next();
			// if (bean.getTid().equals(tid)
			// &&bean.getPid().equals(pid)&&bean.getId().equals(id)) {
			// itr.remove();
			// }
			//
			// }
			// notifyDataSetChanged();
			//
			// }
			// }).errorListener(new XErrorListener() {
			//
			// @Override
			// public void onErrorResponse(Exception exception, int code, String
			// msg) {
			// Toast.makeText(App.ctx, "删除失败", 1).show();
			// }
			// });
			//
			// MyJsonRequest<String> request = builder.build();
			// HttpRequest.getDefaultRequestQueue().add(request);
			// }
			// });
			convertView.setTag(holder);

		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		A replyInfo = dataList.getComments().get(position);

		holder.content.setText(replyInfo.getComment());
		// if (replyInfo.getUserInfo()==null) {
		holder.txt_rname.setText(dataList.getauthor());
		holder.txt_rname2.setText(replyInfo.getauthor());
		// }else{
		// holder.name.setText(replyInfo.getNickname());
		// }
		// holder.time.setText(replyInfo.getDatelineShow());

		// if (commontBean.getUserInfo()!=null) {
		// if (myId.equals(commontBean.getUserInfo().getId())) {
		// holder.delete.setVisibility(View.VISIBLE);
		// }else{
		// holder.delete.setVisibility(View.GONE);
		// }
		// }else if(myId.equals(commontBean.getAuthorId())){
		// holder.delete.setVisibility(View.VISIBLE);
		// }else{
		// holder.delete.setVisibility(View.GONE);
		// }
		//
		// try {
		// holder.head.setImageBitmap(null);
		// XImageLoader.load(NetPublicConstant.IMAGE_URL+commontBean.getUserInfo().getHead()
		// , holder.head);
		// } catch (Exception e) {
		// }

		return convertView;
	}

	class ViewHolder {
		TextView txt_rname,txt_rname2;
		TextView content;
	}

}
